package com.example.musictutor.fragments;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.Fragment;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import com.example.musictutor.R;

import java.util.ArrayList;

/**
 * Created by ironhulk on 2014/05/08.
 */
public class SettingsDialog extends DialogFragment {
    private ArrayList settingsSelected = new ArrayList();

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState){

        final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

        builder.setTitle("Game Settings")
                .setMultiChoiceItems(R.array.app_settings, null,
                        new DialogInterface.OnMultiChoiceClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                                if (isChecked) {
                                    settingsSelected.add(which);
                                } else if (settingsSelected.contains(which)) {
                                    settingsSelected.remove(which);
                                }
                            }
                        }
                )
                .setPositiveButton(R.string.btn_save, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(builder.getContext(),"Settings successfully saved.",3).show();
                    }
                })
                .setNegativeButton(R.string.btn_cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        Toast.makeText(builder.getContext(),"Settings was not saved.",3).show();
                    }

                });
        return builder.create();
    }


}